from typing import List


class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        sum = 0
        inf = int(1e9)
        pay = inf
        for price in prices:
            profit = price - pay
            if profit > 0:
                sum += profit
            pay = price
        return sum


if __name__ == '__main__':
    prices = [7, 1, 5, 3, 6, 4]
    prices2 = [7, 6, 4, 3, 1]
    prices3 = [7, 6, 4, 3, 1]
    s = Solution()
    print(s.maxProfit(prices3))
